package com.alpaak.bootdemo.alpaak;

import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

import java.io.IOException;

/**
 * @author liudongkui
 * @desp
 * @datetime 2019/10/18 16:10
 */
@Configuration
@ComponentScan("com.alpaak.bootdemo")
public class ElConfig {

    @Value("#{systemProperties['os.name']}")
    private String osName;

    @Value("classpath:config/update.txt")
    private Resource testFile;

    public void outPutResource() {
        System.out.println(osName);
        try {
            System.out.println(IOUtils.toString(testFile.getInputStream(),"utf-8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(ElConfig.class);
        ElConfig el = context.getBean(ElConfig.class);
        el.outPutResource();
        context.close();
    }
}
